package com.xinyue.umeng

import android.content.Context
import com.ifmvo.togetherad.core.TogetherAd
import com.ifmvo.togetherad.core.analysis.IAnalysis
import com.ifmvo.togetherad.core.listener.AllAdListener
import com.umeng.analytics.MobclickAgent
import com.umeng.commonsdk.UMConfigure

/**
 * @author liu hong liang
 * @date 2021/3/15
 * 友盟广告统计，在此处进行初始化，并且注册广告sdk的全局监听回调来实现统计分析
 */

object TogetherAsUmeng : IAnalysis {
    val appKeyName: String = "appKey"
    val appChannelName: String = "appChannel"

    override fun init(context: Context, params: Map<String, Any>) {
        UMConfigure.init(
            context,
            params[appKeyName] as String?,
            params[appChannelName] as String?,
            UMConfigure.DEVICE_TYPE_PHONE,
            ""
        )
        TogetherAd.mAllAdListeners.add(object : AllAdListener {
            override fun onAdStartRequest(providerType: String, alias: String) {
                MobclickAgent.onEvent(context, "reward_video_show")
            }

            override fun onAdLoaded(providerType: String, alias: String) {
                super.onAdLoaded(providerType, alias)
            }
        })
    }
}